<script type="text/javascript">
    setTimeout(function(){
        jQuery(".chzn-select").chosen();
    },1);
</script>
<div class="breadcrumbwidget">
	<ul class="skins">
        <li><a href="default" class="skin-color default"></a></li>
        <li><a href="orange" class="skin-color orange"></a></li>
        <li>&nbsp;</li>
        <li class="fixed"><a href="" class="skin-layout fixed"></a></li>
        <li class="wide"><a href="" class="skin-layout wide"></a></li>
    </ul><!--skins-->
	<ul class="breadcrumb">
        <li><a href="<?php echo $baseurl?>">Trang chủ</a> <span class="divider">/</span></li>
        <li class="active">Thêm nhà hàng</li>
    </ul>
</div><!--breadcrumbwidget-->
<div class="pagetitle">
	<h1>Thêm nhà hàng</h1> <span></span>
</div>
<div class="maincontent">
    <?php if(validation_errors()):?>
        <div class="alert alert-error" style="margin: 10px 10px 10px 40px;">
          <button data-dismiss="alert" class="close" type="button">×</button>
          <?php echo validation_errors(); ?>
        </div>
    <?php endif;?>
    <div class="contentinner content-dashboard">    
    
    <p style="margin: 35px 5px 10px 0px;font-size: 18px;">
        Thông tin cơ bản
            <hr style="border-top: 1px soild #DCDCDC !important;margin: 0px;" />
    </p>
    <?php $attr = array('class' => 'stdform'); echo form_open_multipart('', $attr)?>
    
    <p>
    	<label>Tên nhà hàng ( * )</label>
        <span class="field"><input type="text" value="<?php echo $this->input->post('title');?>" name="title" class="input-xxlarge" placeholder="Nhập tên nhà hàng" /></span>
    </p>
    
    <p>
    	<label>Danh mục</label>
        <span class="field">
            <select name="categories[]" id="zone" class="chzn-select input-xxlarge" multiple="multiple" style="width:350px;" tabindex="4">
                <?php echo $danhmucGroupOtp?>
            </select>
        </span>
    </p>
    
    <p>
        <label>Logo đại diện ( * )</label>
        <span class="field cpp">
            <img src="" id="img_show_1" style="display: inline-block; vertical-align: middle;width: 44px;height: 44px;border: 1px solid #CCC;background: #CCC;" />
            <input type="hidden" name="img_hd_1" id="img_hd_1" value="" />
            <input class="uniform-file" type="file" name="img_uploads_1" id="img_1" onchange="convertimage('img', 'img_hd_', 'img_show_', 1);" value="" />
            ( Ảnh jpg, Kích thước 200x200, tối đa 2Mb )
        </span>
    </p>
    
    <p>
        <label>Ảnh đại diện ( * )<br /></label>
        <span class="field cpp">
            <img src="" id="img_show_2" style="display: inline-block; vertical-align: middle;width: 44px;height: 44px;border: 1px solid #CCC;background: #CCC;" />
            <input type="hidden" name="img_hd_2" id="img_hd_2" value="" />
            <input class="uniform-file" type="file" name="img_uploads_2" id="img_2" onchange="convertimage('img', 'img_hd_', 'img_show_', 2);" value="" />
            ( Ảnh jpg, Kích thước 640x760, tối đa 2Mb )
        </span>
    </p>
    <p>
        <label>Hotline nhà hàng </label>
        <span class="field cpp">
            <img src="" id="img_show_3" style="display: inline-block; vertical-align: middle;width: 44px;height: 44px;border: 1px solid #CCC;background: #CCC;" />
            <input type="hidden" name="img_hd_3" id="img_hd_3" value="" />
            <input class="uniform-file" type="file" name="img_uploads_3" id="img_3" onchange="convertimage('img', 'img_hd_', 'img_show_', 3);" value="" />
            ( Ảnh jpg, Kích thước xxx, tối đa 2Mb )
        </span>
    </p>
    <p>
        <label>Số Hotline </label>
        <span class="field"><input type="text" value="<?php echo $this->input->post('phone');?>" name="phone" class="input-xxlarge" placeholder="Nhập số điện thoại hotline" /></span>
    </p>
    <p>
    	<label>Liên kết facebook</label>
        <span class="field"><input type="text" value="<?php echo $this->input->post('share_facebook_url');?>" name="share_facebook_url" class="input-xxlarge" placeholder="Liên kết chia sẻ facebook" /></span>
    </p>
    <!--
    <p style="margin: 35px 5px 10px 0px;font-size: 18px;">
        Thông tin chia sẻ Facebook
            <hr style="border-top: 1px soild #DCDCDC !important;margin: 0px;" />
    </p>
    <p>
    	<label>Tiêu đề facebook</label>
        <span class="field"><input type="text" value="<?php echo $this->input->post('share_facebook_title');?>" name="share_facebook_title" class="input-xxlarge" placeholder="Nhập tiêu đề facebook" /></span>
    </p>
    
    <p>
    	<label>Liên kết chia sẻ facebook</label>
        <span class="field"><input type="text" value="<?php echo $this->input->post('share_facebook_url');?>" name="share_facebook_url" class="input-xxlarge" placeholder="Liên kết chia sẻ facebook" /></span>
    </p>
    
    <p>
        <label>Logo đại diện</label>
        <span class="field cpp">
            <img src="" id="img_show_4" style="display: inline-block; vertical-align: middle;width: 44px;height: 44px;border: 1px solid #CCC;background: #CCC;" />
            <input type="hidden" name="img_hd_4" id="img_hd_4" value="" />
            <input class="uniform-file" type="file" name="img_uploads_4" id="img_4" onchange="convertimage('img', 'img_hd_', 'img_show_', 4);" value="" />
            
        </span>
    </p>
    <p>
    	<label>Mô tả chia sẻ facebook</label>
        <span class="field">
        <textarea cols="80" rows="5" id="textarea2" name="share_facebook_description" class="span5"><?php echo $this->input->post('share_facebook_description');?></textarea>
        </span>
    </p>
    -->
    <p>
        <label></label>
        <button class="btn btn-rounded" type="submit"> <i class="iconfa-ok"></i> &nbsp; Lưu lại</button>
        <button class="btn btn-rounded" type="button" onclick="window.location='<?php echo $baseurl.'manage/restaurant/categories'?>'"> <i class="icon-arrow-right"></i> &nbsp; Hủy bỏ</button>
    </p>
    
    </form>
    </div>
</div>

<script>

function convertimage(id, id_parse, img_show, stv)
{
    var id = id;
    var id_parse = id_parse;
    var img_show = img_show;
    var filesSelected = document.getElementById(id+'_'+stv).files;
    if (filesSelected.length > 0)
    {
        var fileToLoad = filesSelected[0];
        var fileReader = new FileReader();

        fileReader.onload = function(fileLoadedEvent)
        {
            $("#"+id_parse+stv).attr('value', fileLoadedEvent.target.result);
            $("#"+img_show+stv).attr('src', fileLoadedEvent.target.result);
        };

        fileReader.readAsDataURL(fileToLoad);
    }
}

</script>